package com.heima.behavior.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.api.behavior.ApUnlikesBehaviorControllerApi;
import com.heima.behavior.service.ApUnlikesBehaviorServcie;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.behavior.pojos.ApUnlikesBehavior;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author feng js
 */
@RestController
@RequestMapping("/api/v1/unlike_behavior")
public class ApUnlikesBehaviorCotroller implements ApUnlikesBehaviorControllerApi {

    @Autowired
    private ApUnlikesBehaviorServcie apUnlikesBehaviorServcie;

    @PostMapping
    @Override
    public ResponseResult unLike(@RequestBody UnLikesBehaviorDto dto) {
        return apUnlikesBehaviorServcie.unLike(dto);
    }

    @GetMapping("/one")
    @Override
    public ApUnlikesBehavior findUnLikeByArticleIdAndEntryId(@RequestParam("articleId") Long articleId, @RequestParam("entryId") Integer entryId) {
        return apUnlikesBehaviorServcie.getOne(Wrappers.<ApUnlikesBehavior>lambdaQuery()
                .eq(ApUnlikesBehavior::getEntryId,entryId)
                .eq(ApUnlikesBehavior::getArticleId,articleId));
    }
}
